#ifndef NANORCS
#define NANORCS

#include <cstdio>
#include <sys/types.h>
#include <string>
#include <cstring>
#include <iostream>
#include <sys/stat.h>
#include <dirent.h>
#include <fstream>
#include "metadata.h"
#include <unistd.h>
#include <fcntl.h>
#include <cstdlib>

#define MAX_NAME 128

using namespace std;

typedef enum mod { version, date, tag } Mode;
typedef enum tp { file, directory, notFound } Type;
typedef enum cm { last, fixedVersion, versionRange, fixedDate, dateRange, error } ChangesMode;

class Nanorcs
{
private:
	void CheckInFile ( char *filename, char *version = NULL );
	void CheckInDirectory ( char *direcotryName, char *version );
        void CheckInSoftLink(char *name);
        void CheckOutFile ( char *name, Mode mode, char *variable );
        void CheckOutDirectory ( char *name, Mode mode, char *variable );
        void CheckOutSoftLink(char *name);
        void CheckOutHardLinks(char *name, char *targetname = NULL, __ino_t inode = 0 );
        void TagFile ( char *filename );
        void TagDirectory ( char *directory );
        void ChangesFile(char* filename, char *input );
        void ChangesDirectory ( char* name, char *input );
        bool Diff ( const char *targetFilename );
        bool Patch ( void );
	bool IsDirectory ( char *argument );
        void ClearBuffer ( char *buffer, int size );
        void GetOriginalName ( char *filename );
        Type ExistsInRepository ( char *name );
        bool IsSoftLink ( char *name );
        bool CheckInHardLink ( const char *path, char *filename, struct stat stat);
        ChangesMode GetChangesMode ( char *input );
        void GetBounds ( char *input, char **firstBound, char **secondBound );
public:
	void CheckIn ( char *name, char *version = NULL );
        void CheckOut ( char *name, Mode mode = version, char *variable = NULL );
        void TagProject ( char *name );
        void Changes ( char *name, char *input = NULL );
};

#endif
